<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <title>All pages</title>
    <style>
        .info-title{
            color: white;
            font-size: 14px;
            background-color: blue;
            line-height: 26px;
            padding: 0px 0 0 6px;
            font-weight: lighter;
            letter-spacing: 1px
        }
        .info-content{
            padding: 4px;
            color: #666666;
            line-height: 23px;
            font: 12px Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial;
        }
        .info-content img{
            float: left;
            margin: 3px;
        }
    </style>
     <style type="text/css">
        #panel {
            position: absolute;
            background-color: white;
            max-height: 80%;
            overflow-y: auto;
            top: 10px;
            right: 10px;
            width: 250px;
            border: solid 1px silver;
        }
    </style>
    
    <script src="http://webapi.amap.com/maps?v=1.3&key=4a1544569e55725c75df064bde40a897&plugin=AMap.PlaceSearch,AMap.AdvancedInfoWindow"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body>
<input type="text" />查询
<div id="container"></div>
<div id="panel"></div>
<div id="tip">
<input type="text" id="keyword" name="keyword" value="请输入关键字：(选定后搜索)" onfocus="this.value='';"/>
</div>
<script>
	/**
	api位置  图层 》 图片图层 
	*/
    var imageLayer = new AMap.ImageLayer({
        url: '<%=request.getContextPath()%>/common/qh.png',
        bounds: new AMap.Bounds(
                [116.421089,39.930011],
                [116.442375,39.94949]
        ),
        zooms: [15, 18] //图片显示级别范围
    });
   
    var marker, map = new AMap.Map('container', {
        resizeEnable: true,
        center: [116.433277,39.941199],
        zoom: 15,  //显示级别
        layers: [
            new AMap.TileLayer(),//普通地图
            //  new AMap.TileLayer.Satellite(),//卫星图
            imageLayer  //叠加图片
        ],
        isHotspot: true  //开启热点
    });
    
   /***
    	api位置：图层》3D楼块图层
    */
    //3d效果图
    if (document.createElement('canvas') && document.createElement('canvas').getContext && document.createElement('canvas').getContext('2d')) {
        // 实例化3D楼块图层
        var buildings = new AMap.Buildings();
        // 在map中添加3D楼块图层
        buildings.setMap(map);
    } else {
        document.getElementById('tip').innerHTML = "对不起，运行该示例需要浏览器支持HTML5！";
    }
    
    /***
    	api位置：信息窗体》给多个点添加信息窗体
    */
    
   //热点坐标群组
    var lnglats = [
        [116.432548,39.942877],
       	[116.433749,39.938238],
        [116.427526,39.94008]
    ];
    var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
   	//批量加载热点
    for (var i = 0, marker; i < lnglats.length; i++) {
        var marker = new AMap.Marker({
            position: lnglats[i],
            icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_r.png",
            map: map
        });
        marker.content = '<div class="info-title">高德地图'+i+'</div><div class="info-content">' +
            '<img src="http://webapi.amap.com/images/amap.jpg">' +
            '高德是中国领先的数字地图内容、导航和位置服务解决方案提供商。<br/>' +
            '<a target="_blank" href = "http://mobile.amap.com/">点击下载高德地图</a></div>';
        marker.on('click', markerClick); //添加点击事件
       // marker.emit('click', {target: marker});一加载页面就出现提示
    }
    //热点点击事件
    function markerClick(e) {
        infoWindow.setContent(e.target.content);
        infoWindow.open(map, e.target.getPosition());
    }
  //  map.setFitView();热点定位
     
      
    /***
    	api位置：地图显示》地图热点
    */
     
    var placeSearch = new AMap.PlaceSearch();  //构造地点查询类
    var infoWindow=new AMap.AdvancedInfoWindow({
    	panel:"panel"  //返回信息面板  》具体参数：http://lbs.amap.com/api/javascript-api/reference/plugin/ 》AdvancedInfoWindow
    });
    map.on('hotspotclick', function(result) {
        placeSearch.getDetails(result.id, function(status, result) {
            if (status === 'complete' && result.info === 'OK') {
                placeSearch_CallBack(result);
            }
        });
    });
   //回调函数
    function placeSearch_CallBack(data) { //infoWindow.open(map, result.lnglat);
        var poiArr = data.poiList.pois;
        var location = poiArr[0].location;
        infoWindow.setContent(createContent(poiArr[0]));
        infoWindow.open(map,location);
    } 
    function createContent(poi) {  //信息窗体内容
        var s = [];
        s.push('<div class="info-title">'+poi.name+'</div><div class="info-content">'+"地址：" + poi.address);
        s.push("电话：" + poi.tel);
        s.push("类型：" + poi.type);
        s.push('<div>');
        return s.join("<br>");
    }
    
    AMap.event.addListener( infoWindow, 'complete', succ); //查询成功 监听事件 执行succ函数
    function succ(info,type,data){
    	alert("开始查询....");
    }
    
    //
</script>
</body>
</html>